package com.ruoyi.system.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.domain.TeaShopEmployee;
import com.ruoyi.system.domain.TeaShopInventory;
import com.ruoyi.system.domain.TeaShopWorkPlace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TeaShopMapper;
import com.ruoyi.system.domain.TeaShop;
import com.ruoyi.system.service.ITeaShopService;
import com.ruoyi.common.core.text.Convert;

/**
 * 茶店信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-12-30
 */
@Service
public class TeaShopServiceImpl implements ITeaShopService 
{
    @Autowired
    private TeaShopMapper teaShopMapper;

    /**
     * 查询茶店信息
     * 
     * @param id 茶店信息主键
     * @return 茶店信息
     */
    @Override
    public TeaShop selectTeaShopById(Long id)
    {
        return teaShopMapper.selectTeaShopById(id);
    }

    /**
     * 查询茶店信息列表
     * 
     * @param teaShop 茶店信息
     * @return 茶店信息
     */
    @Override
    public List<TeaShop> selectTeaShopList(TeaShop teaShop)
    {
        return teaShopMapper.selectTeaShopList(teaShop);
    }

    /**
     * 新增茶店信息
     * 
     * @param teaShop 茶店信息
     * @return 结果
     */
    @Override
    public int insertTeaShop(TeaShop teaShop)
    {
        return teaShopMapper.insertTeaShop(teaShop);
    }

    /**
     * 修改茶店信息
     * 
     * @param teaShop 茶店信息
     * @return 结果
     */
    @Override
    public int updateTeaShop(TeaShop teaShop)
    {
        return teaShopMapper.updateTeaShop(teaShop);
    }

    /**
     * 批量删除茶店信息
     * 
     * @param ids 需要删除的茶店信息主键
     * @return 结果
     */
    @Override
    public int deleteTeaShopByIds(String ids)
    {
        return teaShopMapper.deleteTeaShopByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除茶店信息信息
     * 
     * @param id 茶店信息主键
     * @return 结果
     */
    @Override
    public int deleteTeaShopById(Long id)
    {
        return teaShopMapper.deleteTeaShopById(id);
    }

    @Override
    public List<TeaShopEmployee> selectAllocatedList(TeaShopWorkPlace teaShopWorkPlace)
    {
        return teaShopMapper.selectAllocatedList(teaShopWorkPlace);
    }

    @Override
    public int deleteAllocateEmployee(TeaShopWorkPlace teaShopWorkPlace) {
        return teaShopMapper.deleteAllocateEmployee(teaShopWorkPlace);
    }

    @Override
    public int deleteAllocateEmployees(Long teaShopId, String employeeIds) {
        return teaShopMapper.deleteAllocateEmployees(teaShopId, Convert.toLongArray(employeeIds));
    }

    @Override
    public List<TeaShopEmployee> selectUnAllocatedList(TeaShopWorkPlace teaShopWorkPlace)
    {
        return teaShopMapper.selectUnAllocatedList(teaShopWorkPlace);
    }
    @Override
    public int insertUnAllocateEmployees(Long teaShopId, String employeeIds) {
        Long[] employees = Convert.toLongArray(employeeIds);
        // 新增用户与角色管理
        List<TeaShopWorkPlace> list = new ArrayList<TeaShopWorkPlace>();
        for (Long employeeId : employees)
        {
            TeaShopWorkPlace temp = new TeaShopWorkPlace();
            temp.setTeaShopId(teaShopId);
            temp.setEmployeeId(employeeId);
            list.add(temp);
        }
        return teaShopMapper.insertUnAllocateEmployees(list);
    }

    @Override
    public List<TeaShopInventory> selectTeaShopInventoryList(TeaShopInventory teaShopInventory) {
        return teaShopMapper.selectTeaShopInventoryList(teaShopInventory);
    }
}
